'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	const db = uniCloud.database(); //代码块为cdb
	let callback = {}
	
	let queryStringParameters = event.queryStringParameters
	const collection = db.collection('navList');
	let res = await collection.get()  
	// 分页查询
	// let res = await collection.skip((queryStringParameters.page-1)* queryStringParameters.pageSize).limit(queryStringParameters.pageSize).get()
	console.log('res.data : ',res.data)
	if (res.data.length == 0) {
		callback = {
			mesg: '获取失败！',
			code: 500,
			data:{}
		}
	} else {
		callback = {
			mesg: '获取成功!',
			code: 200,
			data: res.data
		}
	}
	//返回数据给客户端
	return callback
};
